/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package parismetro;

import javafx.scene.CustomNode;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Stack;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import parismetro.Main;
import javafx.scene.Node;
import javafx.scene.paint.Color;
import java.lang.Boolean;
import modele.ParisVisite;

/**
 * @author Hadrien
 */
def f: Font = Font { size: 48, embolden: true };

public class ZoneParisVisiteButton extends CustomNode {

    public-init var zone: String;
    public var coul: Color = Color.WHITE;
    public var s: Stack = Stack {
                //effect: bind e
                content: [
                    Rectangle {
                        arcWidth: 10, arcHeight: 10
                        fill: Color.WHITE
                        height: 95;
                        width: 95;
                    }
                    Text {
                        font: f
                        content: "{zone}"
                        fill: bind coul
                    }
                ]
                onMousePressed: function(e: MouseEvent): Void {
                    if (Main.orderList.getLast() instanceof ParisVisite) {
                        (Main.orderList.getLast() as ParisVisite).zone = zone;
                    }
                }
            }
    public var isSelected: Boolean = bind {
                if (Main.orderList.getLast() instanceof ParisVisite) {
                    (Main.orderList.getLast() as ParisVisite).zone == zone;
                } else
                    false;
            } on replace {
                if (isSelected) {
                    coul = Color.BLACK;
                } else {
                    coul = Color.rgb(200, 200, 200);
                }
            };

    override public function create(): Node {
        return s;
    }

}
